//
//  FileCache.m
//  SalesLink
//
//  Created by administrator on 8/29/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "FileCache.h"

@implementation FileCache

+(NSString*) createCachePathForKey:(NSString*)key
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *path = [paths objectAtIndex: 0];    
    //NSInteger now = [[NSDate date] timeIntervalSince1970];  
    
   // NSString *strtimestamp = [NSString stringWithFormat:@"%i",now];

    //NSString *fullPath = [NSString stringWithFormat:@"%@/%@_%@.jpg",[path retain],[key retain], [strtimestamp retain]];
    NSString *fullPath = [NSString stringWithFormat:@"%@/%@",path,[key retain]];

    return fullPath;
}
+(UIImage*) getImageFromCacheWithKey:(NSString*)key
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *path = [paths objectAtIndex: 0];
    NSString *fullPath = [NSString stringWithFormat:@"%@/%@",path,[key retain]];
    
    return [UIImage imageWithContentsOfFile:fullPath];
}
+(BOOL) isCacheFileExist:(NSString*) filePath
{
	return [[NSFileManager defaultManager] fileExistsAtPath:filePath];
}

@end
